package com.xwaf.platform.web;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.xwaf.platform.web.config.netty.WebSocketNettyClient;
import com.xwaf.platform.web.config.netty.WebSocketNettyClientConfig;

//import com.xwaf.platform.web.config.netty.NettyClient;

/**
 * 
 * <p>
 * 启动器
 * <p>
 * 
 * @author 李聪 <br>
 * @email xwaf_love@yeah.net <br>
 * @since JDK 1.8<br>
 * @date 2019年12月30日 上午9:42:16 <br>
 * @see 无<br>
 *      Copyright (c) 2019, xwaf_love@yeah.net All Rights Reserved.<br>
 */
@Component
@Order(2)
public class WebCommandLineRunner implements CommandLineRunner {

	private static final Logger LOGGER = LoggerFactory.getLogger(WebCommandLineRunner.class);
	
	@Resource
	private WebSocketNettyClientConfig webSocketNettyClientConfig;

	@Resource
	private WebSocketNettyClient webSocketNettyClient;

	@Override
	public void run(String... args) throws Exception {
		// netty客户端监听器
		// LOGGER.info("{} -> [准备进行与服务端通信]", this.getClass().getName());
		// 获取服务器监听的端口
		// int port = 12345;
		// 获取服务器IP地址
		// String url = "127.0.0.1";
		// 启动NettyClient
		// new NettyClient(port, url).start();
		
		webSocketNettyClient.run(webSocketNettyClientConfig.getHost(), webSocketNettyClientConfig.getPort());
	}
}
